﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

public class Gio_Hang:DataTable
{
    public Gio_Hang()
    {
        DataColumn cot = this.Columns.Add("Masanpham", typeof(System.Int32));
        this.Columns.Add("Tensanpham", typeof(System.String));
        this.Columns.Add("Giaban", typeof(System.Decimal));
        this.Columns.Add("Hinhthunho", typeof(System.String));
        this.Columns.Add("So_luong", typeof(System.Int32));
        this.Columns.Add("Thanh_tien", typeof(System.Double),"So_luong*Giaban");
        this.PrimaryKey = new DataColumn[] { cot };
    }
    public int Tong_so_mat_hang
    {
        get { return this.Rows.Count; }
    }
    public double tong_gia_tri
    {
        get
        {
            double kq = 0;
            object tong = this.Compute("Sum(Thanh_tien)", "");
            if (!(tong is DBNull)) kq = (double)tong;
            //if (tong != DBNull.Value) kq = (double)tong;
            return kq;
        }
    }
}
